package framework;

import java.io.File;

import org.newdawn.slick.Animation;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;

public class StickmanAnimationManager extends NartanAnimationManager {

	public StickmanAnimationManager() {
		init();
	}
	
	public void init() {
		try {
			this.sprite = new Image(C.ASSETS_CHAR_FOLDER + "Stickman" + File.separator + "sprites.png");
		} catch (SlickException e) {
			e.printStackTrace();
		}
		sprites = new SpriteSheet(this.sprite, 227, 284, 0, 0);
		initIdleAnimation();
		initJumpingAnimation();
		initWalkingAnimation();
		initGuardAnimation();
		initHitAnimation();
	}

	@Override
	public void initIdleAnimation() {
		Image[] frames = new Image[2];
		frames[0] = getSpriteSheet().getSprite(0, 0);
		frames[1] = getSpriteSheet().getSprite(0, 1);
		this.idleAnimation = new Animation(frames, 300);
		this.idleAnimationBackward = Util.getFlippedAnimation(this.idleAnimation, true, false);
	}
	
	@Override
	public void initJumpingAnimation() {
		Image[] frames = new Image[1];
		frames[0] = getSpriteSheet().getSprite(2, 1);
		this.jumpingAnimation = new Animation(frames, 500);
		this.jumpingAnimationBackward = Util.getFlippedAnimation(this.jumpingAnimation, true, false);
	}
	
	@Override
	public void initWalkingAnimation() {
		Image[] frames = new Image[2];
		frames[0] = getSpriteSheet().getSprite(0, 0);
		frames[1] = getSpriteSheet().getSprite(3, 0);
		this.walkingAnimation = new Animation(frames, 200);
		this.walkingAnimationBackward = Util.getFlippedAnimation(this.walkingAnimation, true, false);
	}
	
	@Override
	public void initGuardAnimation() {
		Image[] frames = new Image[1];
		frames[0] = getSpriteSheet().getSprite(3, 1);
		this.guardAnimation = new Animation(frames, 200);
		this.guardAnimationBackward = Util.getFlippedAnimation(this.guardAnimation, true, false);
	}
	
	@Override
	public void initHitAnimation() {
		Image[] frames = new Image[1];
		frames[0] = getSpriteSheet().getSprite(0, 0);
		this.hitAnimation = new Animation(frames, 200);
		this.hitAnimationBackward = Util.getFlippedAnimation(this.hitAnimation, true, false);
	}
}
